
Partial Class Reportes_Controls_ctlReporteAltas
    Inherits System.Web.UI.UserControl
    Dim fechainicio As Date
    Dim fechafinal As Date
    Dim dato As String
    Dim sError As String = ""

    Public Sub ShowReport(ByVal IncludeDateRange As Boolean, ByVal AttendanceStartDate As Date, ByVal AttendanceEndDate As Date)

        'Dim m As TimeLiveDataSet.vueAccountAttendanceForLeaveSummaryDataTable
        'm = New AccountEmployeeAttendanceBLL().GetDataForLeaveSummaryReport(DBUtilities.GetSessionAccountId, AccountEmployeeId, IncludeDateRange, AttendanceStartDate, AttendanceEndDate)
        'Me.C1WebReport1.Report.DataSource.Recordset = m
        'C1WebReport1.Report.Tag = DateTime.Now.ToString()
        'Me.C1WebReport1.DataBind()

        ' Dim Report As New DevExpress.XtraReports.Web.ReportViewer

        'Dim ds As New ReporteAltas.viewAltasSociosDataTable

        'Dim dap = ds.viewAltasSociosRow(
        ' e()
        'Me.ReportViewer1.Report = 
        'Me.ReportViewer1.DataBind()


        ASPxGridView1.DataBind()
       


    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Me.IsPostBack Then
            ReportUtilities.SetDefaultValuesOfFilerItem(Me.txtStartDate, Me.txtEndDate, Me.chkIncludeDateRange)
            Me.ShowReportFromFilter()
        Else
            Me.ShowReportFromFilter()
        End If

    End Sub

    Public Sub ShowReportFromFilter()

        lblMensaje.Visible = False
        If valida(sError) = True Then
            Me.ShowReport(chkIncludeDateRange.Checked, Me.txtStartDate.Value, Me.txtEndDate.Value)
        Else
            lblMensaje.Visible = True
            lblMensaje.Text = sError

        End If
    End Sub
   

    Protected Sub chkIncludeDateRange_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        If chkIncludeDateRange.Checked = True Then
            Me.txtStartDate.Enabled = True
            Me.txtEndDate.Enabled = True
            Me.txtRange.Text = "1"
        Else
            Me.txtStartDate.Enabled = False
            Me.txtEndDate.Enabled = False
            Me.txtRange.Text = "0"
        End If
    End Sub

    Protected Sub btnExportar_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Me.ASPxGridViewExport.GridViewID = "ASPxGridView1"
        Me.ASPxGridViewExport.WriteXlsToResponse()
    End Sub

    Protected Sub btnRefrescar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRefrescar.Click
        fechainicio = Me.txtStartDate.Value()
        fechafinal = Me.txtEndDate.Value()
        Me.ViewState.Add("IsFromFilter", True)
        Me.ShowReportFromFilter()
    End Sub

    Protected Sub btnImprimir_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnImprimir.Click
        Me.ASPxGridViewExport.GridViewID = "ASPxGridView1"
        Me.ASPxGridViewExport.WritePdfToResponse()
    End Sub

    Function valida(ByRef sError As String) As Boolean
        valida = False
        If Me.txtStartDate.Value > Now() Then
            sError = "Fecha Inicial no puede ser mayor a la actual"
            Exit Function
        End If
        If Me.txtEndDate.Value > Now() Then
            sError = "Fecha Final no puede ser mayor a la actual"
            Exit Function
        End If
        If Me.txtEndDate.Value > Me.txtStartDate.Date Then
            sError = "Fecha Final no puede ser mayor a la Fecha inicial"
            Exit Function
        End If
        valida = True
    End Function
End Class
